---t_skill.csv
---@class T_skillBean
local T_skillBean = ClientFight.CreateClass("T_skillBean")
function T_skillBean:ctor()
    ----/** 技能ID */
    --@TplAttr(name = "f_SkillID")
    self.f_SkillID = 0

    --/** 技能名称 */
    --@TplAttr(name = "f_SkillName")
    self.f_SkillName = ""

    --/** 技能描述 */
    --@TplAttr(name = "f_Desc")
    self.f_Desc = ""

    --/** 使用距离限制（万分比） */
    --@TplAttr(name = "f_RangeLimit")
    ---@type number[]
    self.f_RangeLimit = nil

    --/** 使用距离限制(圆形) */
    --@TplAttr(name = "f_CircleRangeLimit")
    self.f_CircleRangeLimit = 0

    --/** 技能前摇时间 */
    --@TplAttr(name = "f_PrepareTime")
    self.f_PrepareTime = 0

    --/** 技能使用限制 */
    --@TplAttr(name = "f_SkillLimit")
    ---@type number[][]
    self.f_SkillLimit = nil

    --/** 技能持续时间 */
    --@TplAttr(name = "f_GuideTime")
    self.f_GuideTime = 0

    --/** 技能增加SP点 */
    --@TplAttr(name = "f_GetSP")
    self.f_GetSP = 0

    --/** 冷却时间（毫秒） */
    --@TplAttr(name = "f_Cd")
    self.f_Cd = 0

    --/** 初始冷却时间（毫秒） */
    --@TplAttr(name = "f_CdIni")
    self.f_CdIni = 0

    --/** 技能使用优先级 */
    --@TplAttr(name = "f_SkillPriority")
    self.f_SkillPriority = 0

    --/** 攻击命中时间 */
    --@TplAttr(name = "f_DelayTime")
    self.f_DelayTime = ""

    --/** 技能触发其他技能时间 */
    --@TplAttr(name = "f_SkillBySkill")
    self.f_SkillBySkill1 = ""
    ---@type number[] DynamicParam
    self.f_SkillBySkill1Dynamicparam = nil --//懒得用反射封装了, 直接简单粗暴点存储预加载内容
    ---@type number[][]
    self.f_SkillBySkill = nil

    --/** 技能释放时添加buff */
    --@TplAttr(name = "f_BuffBySkill")
    self.f_BuffBySkill1 = ""
    ---@type number[] DynamicParam
    self.f_BuffBySkill1Dynamicparam = nil --//懒得用反射封装了, 直接简单粗暴点存储预加载内容
    ---@type number[][]
    self.f_BuffBySkill = nil

    --/** 伤害造成前添加buff */
    --@TplAttr(name = "f_DamageBeforeBuff")
    self.f_DamageBeforeBuff = ""

    --/** 伤害造成后添加buff */
    --@TplAttr(name = "f_DamageAfterBuff")
    self.f_DamageAfterBuff = ""

    --/** 使用方式 */
    --@TplAttr(name = "f_TriggerType")
    self.f_TriggerType = 0

    --/** 技能类型 */
    --@TplAttr(name = "f_SkillType")
    self.f_SkillType = 0

    --/** 是否分离技能 */
    --@TplAttr(name = "f_SkillOut")
    self.f_SkillOut = 0

    --/** 技能偏移 */
    --@TplAttr(name = "f_SkillShifting")
    ---@type number[]
    self.f_SkillShifting = nil

    --/** 技能形状 */
    --@TplAttr(name = "f_SkillShape")
    ---@type number[]
    self.f_SkillShape = nil

    --/** 移动速度（单位：像素*200000/秒） */
    --@TplAttr(name = "f_Speed")
    self.f_Speed = 0

    --/** 技能移动时间 */
    --@TplAttr(name = "f_moveFrame")
    self.f_moveFrame = 0

    --/** 技能结束方式 */
    --@TplAttr(name = "f_SkillOver")
    self.f_SkillOver = 0

    --/** 技能命中方式 */
    --@TplAttr(name = "f_SkillHit")
    self.f_SkillHit = 0

    --/** 技能指向方式 */
    --@TplAttr(name = "f_SkillPoint")
    self.f_SkillPoint = 0

    --/** 指向目标是否可以重复 */
    --@TplAttr(name = "f_SkillPointRepeat")
    self.f_SkillPointRepeat = 0

    --/** 作用对象 */
    --@TplAttr(name = "f_Target")
    self.f_Target = 0

    --/** 目标选择规则 */
    --@TplAttr(name = "f_TargetRule")
    self.f_TargetRule = 0

    --/** 目标选择范围 */
    --@TplAttr(name = "f_TargetRange")
    self.f_TargetRange = 0

    --/** 伤害范围形状 */
    --@TplAttr(name = "f_AreaShape")
    self.f_AreaShape = 0

    --/** 伤害范围中心点 */
    --@TplAttr(name = "f_AreaTarget")
    self.f_AreaTarget = 0

    --/** 矩形长宽(像素） */
    --@TplAttr(name = "f_CircleRadius")
    ---@type number[]
    self.f_CircleRadius = nil

    --/** 伤害目标是否可以重复选择 */
    --@TplAttr(name = "f_TargetRepeat")
    self.f_TargetRepeat = 0

    --/** 作用人数上限 */
    --@TplAttr(name = "f_TargetMax")
    self.f_TargetMax = 0

    --/** 技能消耗SP点 */
    --@TplAttr(name = "f_UseSP")
    self.f_UseSP = 0

    --/** 伤害类型 */
    --@TplAttr(name = "f_HurtMethod")
    self.f_HurtMethod = 0

    --/** 伤害计算属性类型 */
    --@TplAttr(name = "f_TriggerFigthHurt")
    self.f_TriggerFigthHurt = 0

    --/** 伤害基础值 */
    --@TplAttr(name = "f_HurtBase")
    ---@type number[]
    self.f_HurtBase = nil

    --/** 伤害修正系数（万分比） */
    --@TplAttr(name = "f_HurtCorrectFactor")
    self.f_HurtCorrectFactor1 = ""
    ---@type number[] DynamicParam
    self.f_HurtCorrectFactor1Dynamicparam = nil --//懒得用反射封装了, 直接简单粗暴点存储预加载内容
    ---@type number[]
    self.f_HurtCorrectFactor = nil

    --/** 目标死亡后是否继续释放 */
    --@TplAttr(name = "f_dieContinue")
    self.f_dieContinue = 0

    --/** 针对召唤物或英雄 */
    --@TplAttr(name = "f_AimTarget")
    self.f_AimTarget = 0

    --/** 调用脚本编号 */
    --@TplAttr(name = "f_SkillScript")
    self.f_SkillScript = "";

    --/** 调用脚本参数 */
    --@TplAttr(name = "f_SkillScriptParameter")
    ---@type number[]
    self.f_SkillScriptParameter = nil

    --/** 子弹时间（毫秒） */
    --@TplAttr(name = "f_BulletTime")
    self.f_BulletTime = 0

    --/** 是否可以移动到内边界外 */
    --@TplAttr(name = "f_Out")
    self.f_Out = 0

    --/** 技能表现ID */
    --@TplAttr(name = "f_SkillShowID")
    self.f_SkillShowID = 0

    --/** 是否子弹技能 */
    --@TplAttr(name = "f_BulletTpye")
    self.f_BulletTpye = 0

    --/** 选择生效BUFF标记 */
    --@TplAttr(name = "f_TagActivate")
    ---@type number[]
    self.f_TagActivate = {}

    --/** 攻击命中时间并触发buff[[时间,buffId,层数],[时间,buffId,层数]] */
    --@TplAttr(name = "f_DelayTimeByBuff")
    self.f_DelayTimeByBuff1 = ""
    ---@type number[] DynamicParam
    self.f_DelayTimeByBuff1Dynamicparam = {} --//懒得用反射封装了, 直接简单粗暴点存储预加载内容
    ---@type number[][]
    self.f_DelayTimeByBuff = {}

    --/** 召唤召唤物 */
    --@TplAttr(name = "f_SummonThing")
    self.f_SummonThing1 = ""
    ---@type number[]
    self.f_SummonThing = {}
    ---@type number[] DynamicParam
    self.f_SummonThing1Dynamicparam = {} --//懒得用反射封装了, 直接简单粗暴点存储预加载内容

    --/** 召唤物位置 */
    --@TplAttr(name = "f_SpawnPositionType")
    ---@type number[]
    self.f_SpawnPositionType = {}

    --/** ai类型 */
    --@TplAttr(name = "f_SummonAiType")
    self.f_SummonAiType = 0

    --/** 召唤召唤物继承属性 */
    --@TplAttr(name = "f_SummonThingAttribute")
    self.f_SummonThingAttribute1 = ""
    ---@type number[][]
    self.f_SummonThingAttribute = {}
    ---@type number[] DynamicParam
    self.f_SummonThingAttribute1Dynamicparam = {} --//懒得用反射封装了, 直接简单粗暴点存储预加载内容
    --/** 技能标签 */
    --@TplAttr(name = "f_SkillLabel")
    ---@type number[]
    self.f_SkillLabel = {}

    --/** 普攻类型 */
    --@TplAttr(name = "f_GeneralAttackType")
    self.f_GeneralAttackType = 0


    --/**
    --* 这个buff包含动态参数
    --*/
    self.dynamicParamSkill = false
end
function T_skillBean:loadCfg(cfg)
    self.f_SkillID = cfg.f_SkillID
    self.f_SkillName = cfg.f_SkillName
    self.f_Desc = cfg.f_Desc
    self.f_RangeLimit = decodeJsonStrToTabel(cfg.f_RangeLimit)
    self.f_CircleRangeLimit = cfg.f_CircleRangeLimit
    self.f_PrepareTime = cfg.f_PrepareTime
    self.f_SkillLimit = decodeJsonStrToTabel(cfg.f_SkillLimit)
    self.f_GuideTime = cfg.f_GuideTime
    self.f_GetSP = cfg.f_GetSP
    self.f_Cd = cfg.f_Cd
    self.f_CdIni = cfg.f_CdIni
    self.f_SkillPriority = cfg.f_SkillPriority
    self.f_DelayTime = cfg.f_DelayTime
    self.f_SkillBySkill1 = cfg.f_SkillBySkill
    self.f_SkillBySkill1Dynamicparam = nil --//懒得用反射封装了, 直接简单粗暴点存储预加载内容
    self.f_SkillBySkill = nil
    self.f_BuffBySkill1 = cfg.f_BuffBySkill
    self.f_BuffBySkill1Dynamicparam = nil --//懒得用反射封装了, 直接简单粗暴点存储预加载内容
    self.f_BuffBySkill = nil
    self.f_DamageBeforeBuff = cfg.f_DamageBeforeBuff
    self.f_DamageAfterBuff = cfg.f_DamageAfterBuff
    self.f_TriggerType = cfg.f_TriggerType
    self.f_SkillType = cfg.f_SkillType
    self.f_SkillOut = cfg.f_SkillOut
    self.f_SkillShifting = decodeJsonStrToTabel(cfg.f_SkillShifting)
    self.f_SkillShape = decodeJsonStrToTabel(cfg.f_SkillShape)
    self.f_Speed = cfg.f_Speed
    self.f_moveFrame = cfg.f_moveFrame
    self.f_SkillOver = cfg.f_SkillOver
    self.f_SkillHit = cfg.f_SkillHit
    self.f_SkillPoint = cfg.f_SkillPoint
    self.f_SkillPointRepeat = cfg.f_SkillPointRepeat
    self.f_Target = cfg.f_Target
    self.f_TargetRule = cfg.f_TargetRule
    self.f_TargetRange = cfg.f_TargetRange
    self.f_AreaShape = cfg.f_AreaShape
    self.f_AreaTarget = cfg.f_AreaTarget
    self.f_CircleRadius = decodeJsonStrToTabel(cfg.f_CircleRadius)
    self.f_TargetRepeat = cfg.f_TargetRepeat
    self.f_TargetMax = cfg.f_TargetMax
    self.f_UseSP = cfg.f_UseSP
    self.f_HurtMethod = cfg.f_HurtMethod
    self.f_TriggerFigthHurt = cfg.f_TriggerFigthHurt
    self.f_HurtBase = decodeJsonStrToTabel(cfg.f_HurtBase)
    self.f_HurtCorrectFactor1 = cfg.f_HurtCorrectFactor
    self.f_HurtCorrectFactor1Dynamicparam = nil --//懒得用反射封装了, 直接简单粗暴点存储预加载内容
    self.f_HurtCorrectFactor = nil
    self.f_dieContinue = cfg.f_dieContinue
    self.f_AimTarget = cfg.f_AimTarget
    self.f_SkillScript = cfg.f_SkillScript
    self.f_SkillScriptParameter = decodeJsonStrToTabel(cfg.f_SkillScriptParameter)
    self.f_BulletTime = cfg.f_BulletTime
    self.f_Out = cfg.f_Out
    self.f_SkillShowID = cfg.f_SkillShowID
    self.f_BulletTpye = cfg.f_BulletTpye
    self.f_TagActivate = decodeJsonStrToTabel(cfg.f_TagActivate) or {}
    self.f_DelayTimeByBuff1 = cfg.f_DelayTimeByBuff
    self.f_DelayTimeByBuff1Dynamicparam = nil --//懒得用反射封装了, 直接简单粗暴点存储预加载内容
    self.f_DelayTimeByBuff = nil
    self.f_SummonThing1 = cfg.f_SummonThing
    self.f_SummonThing = nil
    self.f_SummonThing1Dynamicparam = nil --//懒得用反射封装了, 直接简单粗暴点存储预加载内容
    self.f_SpawnPositionType = decodeJsonStrToTabel(cfg.f_SpawnPositionType)
    self.f_SummonAiType = cfg.f_SummonAiType
    self.f_SummonThingAttribute1 = cfg.f_SummonThingAttribute
    self.f_SummonThingAttribute = nil
    self.f_SummonThingAttribute1Dynamicparam = nil --//懒得用反射封装了, 直接简单粗暴点存储预加载内容
    self.f_SkillLabel = decodeJsonStrToTabel(cfg.f_SkillLabel)
    self.f_GeneralAttackType = cfg.f_GeneralAttackType
    self.dynamicParamSkill = false
end
function T_skillBean:afterLoadSkill()
    --懒得用反射封装了, 直接简单粗暴点做预加载内容, 以后要是有新增的字段里也带动态参数, 自己新增这个字段的解析就行了
    if (not self:containsDynamic(self.f_SummonThingAttribute1)) then
        self.f_SummonThingAttribute = decodeJsonStrToTabel(self.f_SummonThingAttribute1);
    else
        self.f_SummonThingAttribute1Dynamicparam = self:analysisDynamicName(self.f_SummonThingAttribute1)
    end
    if (not self:containsDynamic(self.f_DelayTimeByBuff1)) then
        self.f_DelayTimeByBuff = decodeJsonStrToTabel(self.f_DelayTimeByBuff1)
    else
        self.f_DelayTimeByBuff1Dynamicparam = self:analysisDynamicName(self.f_DelayTimeByBuff1);
    end
    if (not self:containsDynamic(self.f_BuffBySkill1)) then
        self.f_BuffBySkill = decodeJsonStrToTabel(self.f_BuffBySkill1)
    else
        self.f_BuffBySkill1Dynamicparam = self:analysisDynamicName(self.f_BuffBySkill1);
    end
    if (not self:containsDynamic(self.f_SkillBySkill1)) then
        self.f_SkillBySkill = decodeJsonStrToTabel(self.f_SkillBySkill1)
    else
        self.f_SkillBySkill1Dynamicparam = self:analysisDynamicName(self.f_SkillBySkill1);
    end
    if (not self:containsDynamic(self.f_HurtCorrectFactor1)) then
        self.f_HurtCorrectFactor = decodeJsonStrToTabel(self.f_HurtCorrectFactor1)
    else
        self.f_HurtCorrectFactor1Dynamicparam = self:analysisDynamicName(self.f_HurtCorrectFactor1);
    end
    if (not self:containsDynamic(self.f_SummonThing1)) then
        self.f_SummonThing = decodeJsonStrToTabel(self.f_SummonThing1)
    else
        self.f_SummonThing1Dynamicparam = self:analysisDynamicName(self.f_SummonThing1);
    end
end
function T_skillBean:analysisDynamicName(fieldValue)
    self.dynamicParamBuff = true
    local values = DynamicParam.valueNames()
    local list = {}
    for k,v in pairs(values) do
        if string.Contains(fieldValue,v) then
            table.insert(list,v)
        end
    end
    return list
end
function T_skillBean:containsDynamic(fieldValue)
    if string.IsEmpty(fieldValue) or type(fieldValue) == "table" then return false end
    local values = DynamicParam.valueNames()
    for k,v in pairs(values) do
        if string.Contains(fieldValue,v) then
            return true
        end
    end
    return false
end
function T_skillBean:cloneInstance()
    return clone(self)
end
---用 角色的数据 去动态替换掉 buff的动态参数
---@param fighter Fighter
function T_skillBean:dynamicParamParse(fighter)
    local dynamicParamMap = fighter.skillDynamicParam[self.f_SkillID]
    if dynamicParamMap == nil then
        SkillRoleMgr.savePathFile("[" .. fighter.fight.frame .. "][BUFF]" .. f_SkillID
               +"[Fighter]:"+fighter.fighterId+" 英雄id:"+fighter.modelId
                .. "解析动态参数字段:失败, 英雄携带的参数列表为空 ");
        return false
    end
    if table.getn(self.f_SummonThingAttribute1Dynamicparam) then
        for k,dynamicParam in pairs(self.f_SummonThingAttribute1Dynamicparam) do
            local value = dynamicParamMap[dynamicParam]
            if value == nil then
                SkillRoleMgr.savePathFile("[" .. fighter.fight.frame .. "][BUFF]" .. f_BuffId
                        +"[Fighter]:"+fighter.fighterId+" 英雄id:"+fighter.modelId
                        .. "解析动态参数字段:buffRemoveCondition1 = "+f_BuffAddCondition1+" 失败, 英雄携带的参数列表: "+JSON.toJSONString(dynamicParamMap));
                return false
            end
            self.f_SummonThingAttribute1 = string.gsub(self.f_SummonThingAttribute1,DynamicParam.nameOf(dynamicParam),value)
        end
        self.f_SummonThingAttribute = decodeJsonStrToTabel(self.f_SummonThingAttribute1);
    end
    if table.getn(self.f_BuffBySkill1Dynamicparam) then
        for k,dynamicParam in pairs(self.f_BuffBySkill1Dynamicparam) do
            local value = dynamicParamMap[dynamicParam]
            if value == nil then
                --SkillRoleMgr.savePathFile(fighter.getFight(), ()-> "[" .. fighter.fight.frame .. "][BUFF]" .. f_BuffId
                --        +"[Fighter]:"+fighter.fighterId+" 英雄id:"+fighter.modelId
                --        .. "解析动态参数字段:buffRemoveCondition1 = "+f_BuffAddCondition1+" 失败, 英雄携带的参数列表: "+JSON.toJSONString(dynamicParamMap));
                return false
            end
            self.f_BuffBySkill1 = string.gsub(self.f_BuffBySkill1,DynamicParam.nameOf(dynamicParam),value)
        end
        self.f_BuffBySkill = decodeJsonStrToTabel(self.f_BuffBySkill1);
    end
    if table.getn(self.f_DelayTimeByBuff1Dynamicparam) then
        for k,dynamicParam in pairs(self.f_DelayTimeByBuff1Dynamicparam) do
            local value = dynamicParamMap[dynamicParam]
            if value == nil then
                --SkillRoleMgr.savePathFile(fighter.getFight(), ()-> "[" .. fighter.fight.frame .. "][BUFF]" .. f_BuffId
                --        +"[Fighter]:"+fighter.fighterId+" 英雄id:"+fighter.modelId
                --        .. "解析动态参数字段:buffRemoveCondition1 = "+f_BuffAddCondition1+" 失败, 英雄携带的参数列表: "+JSON.toJSONString(dynamicParamMap));
                return false
            end
            self.f_DelayTimeByBuff1 = string.gsub(self.f_DelayTimeByBuff1,DynamicParam.nameOf(dynamicParam),value)
        end
        self.f_DelayTimeByBuff = decodeJsonStrToTabel(self.f_DelayTimeByBuff1);
    end
    if table.getn(self.f_HurtCorrectFactor1Dynamicparam) then
        for k,dynamicParam in pairs(self.f_HurtCorrectFactor1Dynamicparam) do
            local value = dynamicParamMap[dynamicParam]
            if value == nil then
                --SkillRoleMgr.savePathFile(fighter.getFight(), ()-> "[" .. fighter.fight.frame .. "][BUFF]" .. f_BuffId
                --        +"[Fighter]:"+fighter.fighterId+" 英雄id:"+fighter.modelId
                --        .. "解析动态参数字段:buffRemoveCondition1 = "+f_BuffAddCondition1+" 失败, 英雄携带的参数列表: "+JSON.toJSONString(dynamicParamMap));
                return false
            end
            self.f_HurtCorrectFactor1 = string.gsub(self.f_HurtCorrectFactor1,DynamicParam.nameOf(dynamicParam),value)
        end
        self.f_HurtCorrectFactor = decodeJsonStrToTabel(self.f_HurtCorrectFactor1);
    end
    if table.getn(self.f_SummonThing1Dynamicparam) then
        for k,dynamicParam in pairs(self.f_SummonThing1Dynamicparam) do
            local value = dynamicParamMap[dynamicParam]
            if value == nil then
                --SkillRoleMgr.savePathFile(fighter.getFight(), ()-> "[" .. fighter.fight.frame .. "][BUFF]" .. f_BuffId
                --        +"[Fighter]:"+fighter.fighterId+" 英雄id:"+fighter.modelId
                --        .. "解析动态参数字段:buffRemoveCondition1 = "+f_BuffAddCondition1+" 失败, 英雄携带的参数列表: "+JSON.toJSONString(dynamicParamMap));
                return false
            end
            self.f_SummonThing1 = string.gsub(self.f_SummonThing1,DynamicParam.nameOf(dynamicParam),value)
        end
        self.f_SummonThing = decodeJsonStrToTabel(self.f_SummonThing1);
    end
    return true
end